package com.tanhua.log.controller;

import com.tanhua.log.service.LogService;
import com.tanhua.log.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manage")
public class LogController {

    @Autowired
    private LogService logService;

    @GetMapping("/logs")
    public PageResult getLoginLog(@RequestParam("pagesize") Integer pagesize,
                                  @RequestParam("page") Integer page,
                                  @RequestParam("sortProp") String sortProp,
                                  @RequestParam("sortOrder") String sortOrder,
                                  @RequestParam("uid") Integer uid) {


        PageResult pageResult = logService.getLoginLog(pagesize,page,sortProp,sortOrder,uid);
        return pageResult;
    }

    @GetMapping("/logsAll")
    public PageResult getLoginLogAll(@RequestParam("pagesize") Integer pagesize,
                                  @RequestParam("page") Integer page,
                                  @RequestParam("sortProp") String sortProp,
                                  @RequestParam("sortOrder") String sortOrder,
                                  @RequestParam("uid") Integer uid) {


        PageResult loginLogAll = logService.getLoginLogAll(pagesize, page, sortProp, sortOrder, uid);
        return loginLogAll;
    }

    @GetMapping("/userFreezing")
    public PageResult getUserFreezing(@RequestParam("pagesize") Integer pagesize,
                                     @RequestParam("page") Integer page,
                                     @RequestParam("sortProp") String sortProp,
                                     @RequestParam("sortOrder") String sortOrder,
                                     @RequestParam("uid") Integer uid) {


        PageResult userFreezing = logService.getUserFreezing(pagesize, page, sortProp, sortOrder, uid);
        return userFreezing;
    }
}

